package com.onpositive.wiki3.catmodels;

import java.util.ArrayList;

import com.onpositive.wiki3.db.catmodel.Category;
import com.onpositive.wiki3.db.catmodel.ICategoryMatcher;

public class ModelTagger implements ICategoryMatcher {

	
	static ICategoryModel[]models_array=new ICategoryModel[9];
	
	static ICategoryModel[]models_array2=new ICategoryModel[9];
	
	public static ICategoryModel getModel(int tag){
		if(tag>0&&tag<=models_array.length){
			return models_array[tag-1];
		}
		return null;
	}
	
	public static ICategoryModel getModel(Category c){
		if (c.getTag()==0){
			tagger.accept(c);
		}
		return getModel(c.getTag());
	}
	
	static {
		models_array[0]=new ClassificatorCategoryModel();//1
		models_array[1]=new SimpleSpecialisationCategoryModel();//2
		models_array[2]=new DateBasedSpecialisationCategoryModel();//3
		models_array[3]=new PuredDateCategoryModel();//4
		models_array[4]=new SystemCategoryModel();//0
		models_array[5]=new PureLocationModel();//5
		models_array[6]=new VerbCatModel();
		models_array[7]=new PluralCatModel();
		models_array[8]=new SimpleStubsModel();
		
		ArrayList<ICategoryModel>ms=new ArrayList<ICategoryModel>();
		ms.add(new SystemCategoryModel());
		ms.add(new ClassificatorCategoryModel());
		ms.add(new DateBasedSpecialisationCategoryModel());
		ms.add(new SimpleSpecialisationCategoryModel());		
		ms.add(new PuredDateCategoryModel());
		ms.add(new PureLocationModel());
		ms.add(new SimpleStubsModel());
		ms.add(new PluralCatModel());
		ms.add(new VerbCatModel());
		models_array2=ms.toArray(models_array2);
	}

	static ModelTagger tagger=new ModelTagger();
	@Override
	public int accept(Category st) {
		if (st.getTag() != 0) {
			return 0;
		}
		for (ICategoryModel m : models_array2) {
			int score = m.score(st);
			if (score != 0) {
				if (st.getTag()==0){
					System.out.println("A");
				}
				return 0;
			}
		}
		st.setTag(ICategoryModel.UNKNOWN);
		return 0;
	}

	 
}
